<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">















 
 
 
 
 
 
 
  
  


<html>
  <head>
    <script type="text/javascript" language="JavaScript">
    ORIGINAL_PAGE_PATH = "/appengine/docs/python/datastore/typesandpropertyclasses.html";
    </script>
    
    
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Types and Property Classes - Google App Engine - Google Code</title>
<script type="text/javascript"><!--
(function(){function a(){this.t={};this.tick=function(c){this.t[c]=(new Date).getTime()};this.tick("start")}var b=new a;window.jstiming={Timer:a,load:b};if(window.external&&window.external.pageT)window.jstiming.pt=window.external.pageT;})();

var _tocPath_ = '/appengine/docs/_toc.ezt';
var codesite_token = null;
//--></script>
<link href="../../../../css/codesite.pack.04102009.css" type="text/css" rel="stylesheet"></link>
<script src="../../../../js/codesite_head.pack.04102009.js" type="text/javascript"></script>
<script type="text/javascript">CODESITE_CSITimer['load'].tick('bhs');</script>
<link rel="search" type="application/opensearchdescription+xml" title="Google Code" href="http://code.google.com/osd.xml" />

<!--[if IE]><link rel="stylesheet" type="text/css" href="../../../../css/iehacks.css" /><![endif]-->

    <link href="../../../../css/semantic_headers.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/local_extensions.css" rel="stylesheet" type="text/css" />
  </head>

  <body class="gc-documentation">

    
    
    
</a>

<div id="gb">
 <span>
  
    <a id="lang-dropdown" class="dropdown" href="http://code.google.com" onclick="return false;"><img class="globeicon" src="../../../../images/globe2_small.png"/><span>English</span></a>
  
 </span>
</div>

<div class="gbh" style="left: 0pt;"></div>
<div class="gbh" style="right: 0pt;"></div>


<style type="text/css">
  #gc-topnav h1 {
    padding: 0 0 0 6px;
  }
</style>


<div id="gc-container">
<a name="top"></a>
<div id="skipto">
  <a href="#gc-pagecontent">Skip to page content</a>
  <a href="#gc-toc">Skip to main navigation</a>
</div>

<div id="gc-header">
  <div id="logo"><a href="http://code.google.com">
  
  
     <img src="../../../../images/cleardot.gif" height="1px" width="1px" alt="Google Code Home Page" id="gc-logo-img"/>
  
  
  </a></div>
  <div id="search">
    <div id="searchForm" class="searchForm">
      <form id="cse" action="http://www.google.com/cse" accept-charset="utf-8" class="gsc-search-box" onsubmit="executeGSearch(document.getElementById('gsearchInput').value); return false;">
      <noscript>
      <input type="hidden" name="cref" value="http://code.google.com/cse/googlecode-context.xml"/>
      </noscript>
        <table class="gsc-search-box" cellpadding="0" cellspacing="0">
          <tbody>
            <tr>
              <td class="gsc-input">
                <input id="gsearchInput" type="text" name="q" maxlength="2048" class="gsc-input" autocomplete="off" title="Google Code Search" style="width:345px"/>
              </td>
              <td class="gsc-search-button">
                <div id="cs-searchresults" onclick="event.cancelBubble = true;"></div>
                <input title="Search" id="gsearchButton" class="gsc-search-button" name="sa" value="Search" type="submit"/>
              </td>
            </tr>
            <tr>
              <td colspan="2" class="greytext">e.g. "templates" or "datastore"</td>
            </tr>
          </tbody>
        </table>
      </form>
    </div> <!-- end searchForm -->
  </div> <!-- end search -->
</div> <!-- end gc-header -->


<div id="codesiteContent">

<a name="gc-topnav-anchor"></a>
<div id="gc-topnav">
  <h1>Google App Engine</h1>
  <ul id="docs" class="gc-topnav-tabs">

    <li id="home_link">
      <a href="../../../index.html" title="Google App Engine home page">Home</a>
    </li>
  
    <li id="docs_link">
      <a href="../../index.html" class="selected" title="Official Google App Engine documentation">Docs</a>
    </li>
  
    <li id="faq_link">
      <a href="../../../kb/index.html" title="Answers to frequently asked questions about Google App Engine">FAQ</a>
    </li>
  
    <li id="articles_link">
      <a href="../../../articles/index.html" title="Focused articles and tutorials for Google App Engine developers">Articles</a>
    </li>
  
    <li>
      <a href="http://googleappengine.blogspot.com/" title="Official Google App Engine blog">Blog</a>
    </li>
  
    <li>
      <a href="../../../community.html" title="Community home for Google App Engine">Community</a>
    </li>
  
    <li>
      <a href="../../../terms.html" title="Google App Engine terms of service">Terms</a>
    </li>
  
    <li>
      <a href="../../../downloads.html" title="Download Google App Engine">Download</a>
    </li>
  

  </ul>
</div> <!-- end gc-topnav -->

    <div class="g-section g-tpl-170">

      <div class="g-unit g-first" id="gc-toc">
        <ul>
  <li><a href="../../../downloads.html">Downloads</a></li>
  <li><a href="http://code.google.com/status/appengine">System Status</a></li>
  <li><a href="http://code.google.com/p/googleappengine/issues/list">Issue Tracker</a></li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Getting Started</h2>
    <ul>
      <li><a href="../../whatisgoogleappengine.html">What Is Google App Engine?</a></li>
      <li><a href="../../java/gettingstarted/index.html">Java</a>
        <ul>
              <li><a href="../../java/gettingstarted/introduction.html">Introduction</a></li>
    <li><a href="../../java/gettingstarted/installing.html">Installing the Java SDK</a></li>
    <li><a href="../../java/gettingstarted/creating.html">Creating a Project</a></li>
    <li><a href="../../java/gettingstarted/usingusers.html">Using the Users Service</a></li>
    <li><a href="../../java/gettingstarted/usingjsps.html">Using JSPs</a></li>
    <li><a href="../../java/gettingstarted/usingdatastore.html">Using the Datastore with JDO</a></li>
    <li><a href="../../java/gettingstarted/staticfiles.html">Using Static Files</a></li>
    <li><a href="../../java/gettingstarted/uploading.html">Uploading Your Application</a></li>

        </ul>
      </li>
      <li><a href="../gettingstarted/index.html">Python</a>
        <ul>
            <li><a href="../gettingstarted/introduction.html">Introduction</a></li>
  <li><a href="../gettingstarted/devenvironment.html">The Development Environment</a></li>
  <li><a href="../gettingstarted/helloworld.html">Hello, World!</a></li>
  <li><a href="../gettingstarted/usingwebapp.html">Using the webapp Framework</a></li>
  <li><a href="../gettingstarted/usingusers.html">Using the Users Service</a></li>
  <li><a href="../gettingstarted/handlingforms.html">Handling Forms With webapp</a></li>
  <li><a href="../gettingstarted/usingdatastore.html">Using the Datastore</a></li>
  <li><a href="../gettingstarted/templates.html">Using Templates</a></li>
  <li><a href="../gettingstarted/staticfiles.html">Using Static Files</a></li>
  <li><a href="../gettingstarted/uploading.html">Uploading Your Application</a></li>

        </ul>
      </li>
    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Java <sup class="new">Early Look</sup></h2>
    <ul>
          <li><a href="../../java/overview.html">Overview</a></li>
    <li><a href="../../java/runtime.html">Servlet Environment</a></li>
    <li><a href="../../java/datastore/index.html">Storing Data</a>
      <ul>
            <li><a href="../../java/datastore/overview.html">Overview</a></li>
    <li><a href="../../java/datastore/usingjdo.html">Using JDO</a></li>
    <li><a href="../../java/datastore/dataclasses.html">Defining Data Classes</a></li>
    <li><a href="../../java/datastore/creatinggettinganddeletingdata.html">Creating, Getting and Deleting Data</a></li>
    <li><a href="../../java/datastore/queriesandindexes.html">Queries and Indexes</a></li>
    <li><a href="../../java/datastore/transactions.html">Transactions</a></li>
    <li><a href="../../java/datastore/relationships.html">Relationships</a></li>
    <li><a href="../../java/datastore/usingjpa.html">Using JPA</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/datastore/package-summary.html">Low-level API</a></li>

      </ul>
    </li>
    <li><a href="../../java/apis.html">Services</a>
      <ul>
        <li><a href="../../java/memcache/index.html">Memcache</a>
          <ul>
                <li><a href="../../java/memcache/overview.html">Overview</a></li>
    <li><a href="../../java/memcache/usingjcache.html">Using JCache</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/memcache/package-summary.html">Low-level API</a></li>

          </ul>
        </li>
        <li><a href="../../java/urlfetch/index.html">URL Fetch</a>
          <ul>
                <li><a href="../../java/urlfetch/overview.html">Overview</a></li>
    <li><a href="../../java/urlfetch/usingjavanet.html">Using java.net</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/urlfetch/package-summary.html">Low-level API</a></li>

          </ul>
        </li>
        <li><a href="../../java/mail/index.html">Mail</a>
          <ul>
                <li><a href="../../java/mail/overview.html">Overview</a></li>
    <li><a href="../../java/mail/usingjavamail.html">Using JavaMail</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/mail/package-summary.html">Low-level API</a></li>

          </ul>
        </li>
        <li><a href="../../java/images/index.html">Images</a>
          <ul>
                <li><a href="../../java/images/overview.html">Overview</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/images/package-summary.html">API Reference</a></li>

          </ul>
        </li>
        <li><a href="../../java/users/index.html">Google Accounts</a>
          <ul>
                <li><a href="../../java/users/overview.html">Overview</a></li>
    <li><a href="../../java/javadoc/com/google/appengine/api/users/package-summary.html">API Reference</a></li>

          </ul>
        </li>
      </ul>
    </li>
    <li><a href="../../java/javadoc/index.html">Javadoc Reference</a></li>
    <li><a href="../../java/jrewhitelist.html">JRE Class White List</a></li>
    <li><a href="../../java/config/index.html">Configuration</a>
      <ul>
            <li><a href="../../java/config/webxml.html">Deployment Descriptor</a></li>
    <li><a href="../../java/config/appconfig.html">App Config</a></li>
    <li><a href="../../java/config/indexconfig.html">Index Config</a></li>
    <li><a href="../../java/config/cron.html">Scheduled Tasks</a></li>

      </ul>
    </li>
    <li><a href="../../java/tools/index.html">Tools</a>
      <ul>
            <li><a href="../../java/tools/devserver.html">Development Server</a></li>
    <li><a href="../../java/tools/uploadinganapp.html">Uploading and Managing</a></li>
    <li><a href="../../java/tools/eclipse.html">Google Plugin for Eclipse</a></li>
    <li><a href="../../java/tools/ant.html">Using Apache Ant</a></li>

      </ul>
    </li>
    <li><a href="../../java/howto/index.html">How-To</a>
      <ul>
              <li><a href="../../java/howto/unittesting.html">Unit Testing</a></li>

      </ul>
    </li>

    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Python</h2>
    <ul>
          <li><a href="../overview.html">Overview</a></li>
    <li><a href="../runtime.html">CGI Environment</a></li>
    <li><a href="index.html">Storing Data</a>
      <ul>
             <li><a href="overview.html">Overview</a></li>
     <li><a href="entitiesandmodels.html">Entities and Models</a></li>
     <li><a href="creatinggettinganddeletingdata.html">Creating, Getting and Deleting Data</a></li>
     <li><a href="keysandentitygroups.html">Keys and Entity Groups</a></li>
     <li><a href="queriesandindexes.html">Queries and Indexes</a></li>
     <li><a href="transactions.html">Transactions</a></li>
     <li><a href="typesandpropertyclasses.html">Types and Property Classes</a></li>
     <li><a href="gqlreference.html">GQL Reference</a></li>

     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="modelclass.html">Model</a></li>
         <li><a href="expandoclass.html">Expando</a></li>
         <li><a href="polymodelclass.html">PolyModel</a></li>
         <li><a href="propertyclass.html">Property</a></li>
         <li><a href="queryclass.html">Query</a></li>
         <li><a href="gqlqueryclass.html">GqlQuery</a></li>
         <li><a href="keyclass.html">Key</a></li>
         <li><a href="functions.html">Functions</a></li>
         <li><a href="exceptions.html">Exceptions</a></li>
       </ul>
     </li>

      </ul>
    </li>
    <li><a href="../apis.html">Services</a>
      <ul>
        <li><a href="../memcache/index.html">Memcache</a>
          <ul>
                 <li><a href="../memcache/overview.html">Overview</a></li>
      <li><a href="../memcache/usingmemcache.html">Using Memcache</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../memcache/clientclass.html">Client</a></li>
         <li><a href="../memcache/functions.html">Functions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../urlfetch/index.html">URL Fetch</a>
          <ul>
                 <li><a href="../urlfetch/overview.html">Overview</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../urlfetch/fetchfunction.html">The fetch Function</a></li>
         <li><a href="../urlfetch/responseobjects.html">Response Objects</a></li>
         <li><a href="../urlfetch/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../mail/index.html">Mail</a>
          <ul>
                 <li><a href="../mail/overview.html">Overview</a></li>
     <li><a href="../mail/sendingmail.html">Sending Mail</a></li>
     <li><a href="../mail/attachments.html">Attachments</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../mail/emailmessageclass.html">EmailMessage</a></li>
         <li><a href="../mail/emailmessagefields.html">Message Fields</a></li>
         <li><a href="../mail/functions.html">Functions</a></li>
         <li><a href="../mail/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../images/index.html">Images</a>
          <ul>
                 <li><a href="../images/overview.html">Overview</a></li>
     <li><a href="../images/installingPIL.html">Installing PIL</a></li>
     <li><a href="../images/usingimages.html">Using the Images API</a></li>
     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../images/imageclass.html">Image</a></li>
         <li><a href="../images/functions.html">Functions</a></li>
         <li><a href="../images/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
        <li><a href="../users/index.html">Google Accounts</a>
          <ul>
                 <li><a href="../users/overview.html">Overview</a></li>
     <li><a href="../users/userobjects.html">User Objects</a></li>
     <li><a href="../users/loginurls.html">Login URLs</a></li>
     <li><a href="../users/adminusers.html">Admin Users</a></li>

     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../users/userclass.html">User</a></li>
         <li><a href="../users/functions.html">Functions</a></li>
         <li><a href="../users/exceptions.html">Exceptions</a></li>
       </ul>
     </li>

          </ul>
        </li>
      </ul>
    </li>
    <li><a href="../config/index.html">Configuration</a>
      <ul>
            <li><a href="../config/appconfig.html">App Config</a></li>
    <li><a href="../config/indexconfig.html">Index Config</a></li>
    <li><a href="../config/cron.html">Scheduled Tasks</a></li>

      </ul>
    </li>
    <li><a href="../tools/index.html">Tools</a>
      <ul>
            <li><a href="../tools/devserver.html">Development Server</a></li>
    <li><a href="../tools/uploadinganapp.html">Uploading and Managing</a></li>
    <li><a href="../tools/uploadingdata.html">Uploading Data</a></li>
    <li><a href="../tools/webapp/index.html">webapp Framework</a>
      <ul>
             <li><a href="../tools/webapp/overview.html">Overview</a></li>
     <li><a href="../tools/webapp/running.html">Running the Application</a></li>
     <li><a href="../tools/webapp/requesthandlers.html">Request Handlers</a></li>
     <li><a href="../tools/webapp/requestdata.html">Request Data</a></li>
     <li><a href="../tools/webapp/buildingtheresponse.html">Building the Response</a></li>
     <li><a href="../tools/webapp/redirects.html">Redirects, Headers and Status Codes</a></li>
     

     <li><span class="tlw-title tlw-expanded">Reference</span>
       <ul>
         <li><a href="../tools/webapp/requestclass.html">Request</a></li>
         <li><a href="../tools/webapp/responseclass.html">Response</a></li>
         <li><a href="../tools/webapp/requesthandlerclass.html">RequestHandler</a></li>
         <li><a href="../tools/webapp/wsgiapplicationclass.html">WSGIApplication</a></li>
         <li><a href="../tools/webapp/utilmodule.html">Utility Functions</a></li>
         
       </ul>
     </li>

      </ul>
    </li>
    <li><a href="../tools/libraries.html">Third-party Libraries</a></li>

      </ul>
    </li>
    <li><a href="../howto/index.html">How-To</a>
      <ul>
              <li><a href="../howto/usinggdataservices.html">Google Data Services</a></li>

      </ul>
    </li>

    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Managing Your App</h2>
    <ul>
      <li><a href="../../theadminconsole.html">The Admin Console</a></li>
      <li><a href="../../quotas.html">Quotas</a></li>
      <li><a href="../../billing.html">Billing</a></li>
    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><h2>Resources</h2>
    <ul>
      <li><a href="../../../kb/index.html">FAQ</a></li>
      <li><a href="../../../articles/index.html">Articles</a></li>
      <li><a href="http://appengine-cookbook.appspot.com/">Cookbook</a></li>
      <li><a href="http://appgallery.appspot.com/">App Gallery</a></li>
      <li><a href="http://code.google.com/p/googleappengine/">SDK Code</a></li>
      <li><a href="http://code.google.com/p/google-app-engine-samples/">Sample Apps Code</a></li>
      <li><a href="../../../community.html">Discussion Groups</a></li>
    </ul>
  </li>
</ul>
<div class="line"></div>
<ul>
  <li><a href="../../roadmap.html">Product Roadmap</a></li>
  <li><a href="http://code.google.com/p/googleappengine/wiki/SdkReleaseNotes">Release Notes</a></li>
  <li><a href="../../revision_history.html">Revision History</a></li>
</ul>

        <a class="hidden" href="#gc-topnav-anchor">More Google App Engine resource links</a>
      </div>

      <div class="g-unit" id="gc-pagecontent">
        <h1 class="page_title">Types and Property Classes</h1>






<p>The App Engine datastore supports a fixed set of value types for properties on data entities.  <a href="propertyclass.html">Property</a> classes can define new types that are converted to and from the underlying value types, and the value types can be used directly with <a href="expandoclass.html">Expando</a> dynamic properties and <a href="#ListProperty">ListProperty</a> aggregate property models.</p>

<p>The following table describes the Property classes whose values correspond directly with the underlying data types.  Any of these value types can be used in an Expando dynamic property or ListProperty aggregate type.</p>

<table>
  <tr>
    <th>Property class</th>
    <th>Value type</th>
    <th>Sort order</th>
  </tr>
  <tr>
    <td><a href="#StringProperty">StringProperty</a></td>
    <td>
      <a href="#str">str</a><br />
      <a href="#str">unicode</a>
    </td>
    <td>Unicode (<code>str</code> is treated as ASCII)</td>
  </tr>
  <tr>
    <td><a href="#ByteStringProperty">ByteStringProperty</a></td>
    <td>
      <a href="#ByteString">ByteString</a><br />
    </td>
    <td>byte order</td>
  </tr>
  <tr>
    <td><a href="#BooleanProperty">BooleanProperty</a></td>
    <td><a href="#bool">bool</a></td>
    <td><code>False</code> &lt; <code>True</code></td>
  </tr>
  <tr>
    <td><a href="#IntegerProperty">IntegerProperty</a></td>
    <td>
      <a href="#int">int</a><br />
      <a href="#int">long</a><br />
    </td>
    <td>Numeric</td>
  </tr>
  <tr>
    <td><a href="#FloatProperty">FloatProperty</a></td>
    <td><a href="#float">float</a></td>
    <td>Numeric</td>
  </tr>
  <tr>
    <td>
      <a href="#DateTimeProperty">DateTimeProperty</a><br />
      <a href="#DateProperty">DateProperty</a><br />
      <a href="#TimeProperty">TimeProperty</a><br />
    </td>
    <td><a href="#datetime">datetime.datetime</a></td>
    <td>Chronological</td>
  </tr>
  <tr>
    <td>
      <a href="#ListProperty">ListProperty</a><br />
      <a href="#StringListProperty">StringListProperty</a>
    </td>
    <td><a href="#list">list</a> of a supported type</td>
    <td>If ascending, by least element; if descending, by greatest element</td>
  </tr>
  <tr>
    <td>
      <a href="#ReferenceProperty">ReferenceProperty</a><br />
      <a href="#SelfReferenceProperty">SelfReferenceProperty</a>
    </td>
    <td><a href="keyclass.html">db.Key</a></td>
    <td>By path elements (kind, ID or name, kind, ID or name...)</td>
  </tr>
  <tr>
    <td><a href="#UserProperty">UserProperty</a></td>
    <td><a href="../users/userclass.html">users.User</a></td>
    <td>By email address (Unicode)</td>
  </tr>
  <tr>
    <td><a href="#BlobProperty">BlobProperty</a></td>
    <td><a href="#Blob">db.Blob</a></td>
    <td>(not orderable)</td>
  </tr>
  <tr>
    <td><a href="#TextProperty">TextProperty</a></td>
    <td><a href="#Text">db.Text</a></td>
    <td>(not orderable)</td>
  </tr>
  <tr>
    <td><a href="#CategoryProperty">CategoryProperty</a></td>
    <td><a href="#Category">db.Category</a></td>
    <td>Unicode</td>
  </tr>
  <tr>
    <td><a href="#LinkProperty">LinkProperty</a></td>
    <td><a href="#Link">db.Link</a></td>
    <td>Unicode</td>
  </tr>
  <tr>
    <td><a href="#EmailProperty">EmailProperty</a></td>
    <td><a href="#Email">db.Email</a></td>
    <td>Unicode</td>
  </tr>
  <tr>
    <td><a href="#GeoPtProperty">GeoPtProperty</a></td>
    <td><a href="#GeoPt">db.GeoPt</a></td>
    <td>By latitude, then longitude</td>
  </tr>
  <tr>
    <td><a href="#IMProperty">IMProperty</a></td>
    <td><a href="#IM">db.IM</a></td>
    <td>Unicode</td>
  </tr>
  <tr>
    <td><a href="#PhoneNumberProperty">PhoneNumberProperty</a></td>
    <td><a href="#PhoneNumber">db.PhoneNumber</a></td>
    <td>Unicode</td>
  </tr>
  <tr>
    <td><a href="#PostalAddressProperty">PostalAddressProperty</a></td>
    <td><a href="#PostalAddress">db.PostalAddress</a></td>
    <td>Unicode</td>
  </tr>
  <tr>
    <td><a href="#RatingProperty">RatingProperty</a></td>
    <td><a href="#Rating">db.Rating</a></td>
    <td>Numeric</td>
  </tr>
</table>


<h2 id="Datastore_Value_Types">Datastore Value Types</h2>

<p>Datastore entity property values can be of one of the following types.  See above for a list of corresponding <a href="propertyclass.html">Property</a> classes to use with <a href="modelclass.html">Model</a> definitions.</p>

<p>Other than the Python standard types and <a href="../users/userclass.html">users.User</a>, all classes described in this section are provided by the <code>google.appengine.ext.db</code> module.</p>

<dl class="apireference">

  <dt id="str"><code>str</code> or <code>unicode</code></dt>
  <dd>
    <p>A short string value, less than 500 bytes in length.</p>
    <p>A <code>str</code> value is assumed to be text encoded with the <code>ascii</code> codec, and is converted to a <code>unicode</code> value before being stored.  The value is returned by the datastore as a <code>unicode</code> value.  For short strings using other codecs, use a <code>unicode</code> value.</p>
    <p>Short strings are indexed by the datastore, and can be used in filters and sort orders.  For text strings longer than 500 bytes (which are not indexed), use a <a href="#Text">Text</a> instance.  For unencoded byte strings longer than 500 bytes (also not indexed), use a <a href="#Blob">Blob</a> instance.</p>
    <p><i>Model property:</i> <a href="#StringProperty">StringProperty</a></p>
  </dd>

  <dt id="bool"><code>bool</code></dt>
  <dd>
    <p>A Boolean value, <code>True</code> or <code>False</code>.</p>
    <p><i>Model property:</i> <a href="#BooleanProperty">BooleanProperty</a></p>
  </dd>

  <dt id="int"><code>int</code> or <code>long</code></dt>
  <dd>
    <p>An integer value.</p>
    <p>Python <code>int</code> values are converted to Python <code>long</code> values prior to storage.  A value stored as an <code>int</code> will be returned as a <code>long</code>.</p>
    <p><i>Model property:</i> <a href="#IntegerProperty">IntegerProperty</a></p>
  </dd>

  <dt id="float"><code>float</code></dt>
  <dd>
    <p>A floating point value.</p>
    <p><i>Model property:</i> <a href="#FloatProperty">FloatProperty</a></p>
  </dd>

  <dt id="datetime"><code>datetime.datetime</code></dt>
  <dd>
    <p>A date and time.  See <a href="http://docs.python.org/lib/module-datetime.html">the datetime module documentation</a>.</p>
    <p>If the <code>datetime</code> value has a <code>tzinfo</code> attribute, it will be converted to the UTC time zone for storage.  Values come back from the datastore as UTC, with a <code>tzinfo</code> of <code>None</code>.  An application that needs date and time values to be in a particular time zone must set <code>tzinfo</code> correctly when updating the value, and convert values to the timezone when accessing the value.</p>
    <p>Some libraries use the <code>TZ</code> environment variable to control the time zone applied to date-time values.  App Engine sets this environment variable to <code>"UTC"</code>.  Note that changing this variable in an application will not change the behavior of some datetime functions, because changes to environment variables are not visible outside of the Python code.</p>
    <p>If you only convert values to and from a particular time zone, you can implement a custom <code>datetime.tzinfo</code> to convert values from the datastore:</p>
    <pre class="prettyprint">
class Pacific_tzinfo(datetime_module.tzinfo):
 """Implementation of the Pacific timezone."""
 def utcoffset(self, dt):
   return datetime_module.timedelta(hours=-8) + self.dst(dt)

 def _FirstSunday(self, dt):
   """First Sunday on or after dt."""
   return dt + datetime_module.timedelta(days=(6-dt.weekday()))

 def dst(self, dt):
   # 2 am on the second Sunday in March
   dst_start = self._FirstSunday(datetime_module.datetime(dt.year, 3, 8, 2))
   # 1 am on the first Sunday in November
   dst_end = self._FirstSunday(datetime_module.datetime(dt.year, 11, 1, 1))

   if dst_start <= dt.replace(tzinfo=None) < dst_end:
     return datetime_module.timedelta(hours=1)
   else:
     return datetime_module.timedelta(hours=0)

 def tzname(self, dt):
   if self.dst(dt) == datetime_module.timedelta(hours=0):
     return "PST"
   else:
     return "PDT"

pacific_time = utc_time.astimezone(Pacific_tzinfo())
</pre>
    <p>See <a href="http://docs.python.org/lib/module-datetime.html">the datetime module documentation</a> (including <a href="http://docs.python.org/lib/datetime-tzinfo.html">datetime.tzinfo</a>).  See also the third-party module <a href="http://pytz.sourceforge.net/">pytz</a>, though note that the pytz distribution has many files.</p>
    <p>The <a href="#DateTimeProperty">DateTimeProperty</a> model property class includes features such as the ability to automatically use the date and time a model instance is stored.  These are features of the model, and are not available on the raw datastore value (such as in an <a href="expandoclass.html">Expando</a> dynamic property).</p>
    <p><i>Model properties:</i> <a href="#DateTimeProperty">DateTimeProperty</a>, <a href="#DateProperty">DateProperty</a>, <a href="#TimeProperty">TimeProperty</a></p>
  </dd>

  <dt id="list"><code>list</code></code></dt>
  <dd>
    <p>A list of values, each of which is of one of the supported data types.  See <a href="entitiesandmodels.html#Lists">Entities and Models: Lists</a>.</p>
    <p>When a <code>list</code> is used as the value of an <a href="expandoclass.html">Expando</a> dynamic property, it cannot be an empty list.  This is due to how list values are stored: When a list property has no items, it has no representation in the datastore.  You can use a static property and the <a href="#ListProperty">ListProperty</a> class to represent an empty list value for a property.</p>
    <p><i>Model property:</i> <a href="#ListProperty">ListProperty</a></p>
  </dd>

  <dt id="db_Key"><a href="keyclass.html">db.Key</a></dt>
  <dd>
    <p>The key for another datastore entity.</p>
    <pre class="prettyprint">
m = Employee(name="Susan", key_name="susan5")
m.put()
e = Employee(name="Bob", manager=m.key())
e.put()

m_key = db.Key.from_path("Employee", "susan5")
e = Employee(name="Jennifer", manager=m_key)
</pre>
    <p><i>Model properties:</i> <a href="#ReferenceProperty">ReferenceProperty</a>, <a href="#SelfReferenceProperty">SelfReferenceProperty</a></p>
  </dd>

  <dt id="users_User"><a href="../users/userclass.html">users.User</a></dt>
  <dd>
    <p>A user with a Google account.</p>
    <p>A User value in the datastore does not get updated if the user changes her email address.  This may be remedied in a future release.  Until then, you can use the User value's <code>user_id()</code> as the user's stable unique identifier.</p>
    <p><i>Model property:</i> <a href="#UserProperty">UserProperty</a></p>
  </dd>

  <dt id="Blob"><span class="type">class</span>&nbsp;<span class="itemname">Blob</span>(<span class="argname">arg</span>=<span class="argdefault">None</span>)</dt>
  <dd>
    <p>Binary data, as a byte string.  This is a subclass of the built-in <code>str</code> type.</p>
    <p>Blob properties are not indexed, and cannot be used in filters or sort orders.</p>
    <p>Blob is for binary data, such as images.  It takes a <code>str</code> value, but this value is stored as a byte string and is not encoded as text.  Use a <a href="#Text">Text</a> instance for large text data.</p>
    <p><i>Model property:</i> <a href="#BlobProperty">BlobProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  blob = db.BlobProperty()

m = MyModel()
m.blob = db.Blob(open("image.png").read())
</pre>
    <p>In XML, blobs are base-64 encoded whether or not they contain binary data.</p>
  </dd>

  <dt id="ByteString"><span class="type">class</span>&nbsp;<span class="itemname">ByteString</span>(<span class="argname">arg</span>)</dt>
  <dd>
    <p>A short blob value (a "byte string"), less than 500 bytes in length.  ByteString is a subclass of <a href="#str">str</a>, and takes an unencoded <code>str</code> value as an argument to its constructor.</p>
    <p>ByteStrings are indexed by the datastore, and can be used in filters and sort orders.  For byte strings longer than 500 bytes (which are not indexed), use a <a href="#Blob">Blob</a> instance.  For encoded text data, use <a href="#str">str</a> (short, indexed) or <a href="#Text">Text</a> (long, not indexed).</p>
    <p><i>Model property:</i> <a href="#ByteStringProperty">ByteStringProperty</a></p>
  </dd>

  <dt id="Text"><span class="type">class</span>&nbsp;<span class="itemname">Text</span>(<span class="argname">arg</span>=<span class="argdefault">None</span>, <span class="argname">encoding</span>=<span class="argdefault">None</span>)</dt>
  <dd>
    <p>A long string.  This is a subclass of the built-in <code>unicode</code> type.</p>
    <p><span class="argname">arg</span> a <code>unicode</code> or <code>str</code> value.  If <span class="argname">arg</span> is a <code>str</code>, then it is parsed with the encoding specified by <span class="argname">encoding</span>, or <code>ascii</code> if no encoding is specified.  See <a href="http://docs.python.org/lib/standard-encodings.html">the list of standard encodings</a> for possible values for <span class="argname">encoding</span>.</p>
    <p>Unlike an entity property whose value is a simple <code>str</code> or <code>unicode</code>, a Text property can be more than 500 bytes long.  However, Text properties are not indexed, and cannot be used in filters or sort orders.</p>
    <p><i>Model property:</i> <a href="#TextProperty">TextProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  text = db.TextProperty()

m = MyModel()
m.text = db.Text(u"kittens")

m.text = db.Text("kittens", encoding="latin-1")
</pre>
  </dd>

  <dt id="Category"><span class="type">class</span>&nbsp;<span class="itemname">Category</span>(<span class="argname">tag</span>)</dt>
  <dd>
    <p>A category or "tag".  This is a subclass of the built-in <code>unicode</code> type.</p>
    <p><i>Model property:</i> <a href="#CategoryProperty">CategoryProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  category = db.CategoryProperty()

m = MyModel()
m.category = db.Category("kittens")
</pre>
    <p>In XML, this is an Atom <code>category</code> element.  See <a href="http://www.atomenabled.org/developers/syndication/#category">the Atom specification</a>.</p>
  </dd>

  <dt id="Email"><span class="type">class</span>&nbsp;<span class="itemname">Email</span>(<span class="argname">email</span>)</dt>
  <dd>
    <p>An email address.  This is a subclass of the built-in <code>unicode</code> type.</p>
    <p>Neither the property class nor the value class perform validation of email addresses, they just store the value.</p>
    <p><i>Model property:</i> <a href="#EmailProperty">EmailProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  email_address = db.EmailProperty()

m = MyModel()
m.email_address = db.Email("larry@example.com")
</pre>
    <p>In XML, this is a <code>gd:email</code> element.  See <a href="http://code.google.com/apis/gdata/common-elements.html#gdEmail">the GData API reference</a>.</p>
  </dd>

  <dt id="GeoPt"><span class="type">class</span>&nbsp;<span class="itemname">GeoPt</span>(<span class="argname">lat</span>, <span class="argname">lon</span>=<span class="argdefault">None</span>)</dt>
  <dd>
    <p>A geographical point represented by floating-point latitude and longitude coordinates.</p>
    <p><i>Model property:</i> <a href="#GeoPtProperty">GeoPtProperty</a></p>
    <p>In XML, this is a <code>georss:point</code> element.  See <a href="http://georss.org/">georss.org</a>.</p>
  </dd>

  <dt id="IM"><span class="type">class</span>&nbsp;<span class="itemname">IM</span>(<span class="argname">protocol</span>, <span class="argname">address</span>=<span class="argdefault">None</span>)</dt>
  <dd>
    <p>An instant messaging handle.</p>
    <p><span class="argname">protocol</span> is the canonical URL of the instant messaging service.  Some possible values:</p>
    <table>
      <tr><th>Protocol</th><th>Description</th></tr>
      <tr><td>sip</td><td>SIP/SIMPLE</td></tr>
      <tr><td>xmpp</td><td>XMPP/Jabber</td></tr>
      <tr><td>http://aim.com/</td><td>AIM</td></tr>
      <tr><td>http://icq.com/</td><td>ICQ</td></tr>
      <tr><td>http://talk.google.com/</td><td>Google Talk</td></tr>
      <tr><td>http://messenger.msn.com/</td><td>MSN Messenger</td></tr>
      <tr><td>http://messenger.yahoo.com/</td><td>Yahoo Messenger</td></tr>
      <tr><td>http://sametime.com/</td><td>Lotus Sametime</td></tr>
      <tr><td>http://gadu-gadu.pl/</td><td>Gadu-Gadu</td></tr>
      <tr><td>unknown</td><td>Unknown or unspecified</td></tr>
    </table>
    <p><span class="argname">address</span> is the handle's address.</p>
    <p><i>Model property:</i> <a href="#IMProperty">IMProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  im = db.IMProperty()

m = MyModel()
m.im = db.IM("http://example.com/", "Larry97")
</pre>
    <p>In XML, this is a <code>gd:im</code> element.  See <a href="http://code.google.com/apis/gdata/common-elements.html#gdIm">the GData API reference</a>.</p>
  </dd>

  <dt id="Link"><span class="type">class</span>&nbsp;<span class="itemname">Link</span>(<span class="argname">link</span>)</dt>
  <dd>
    <p>A fully qualified URL.  This is a subclass of the built-in <code>unicode</code> type.</p>
    <p><i>Model property:</i> <a href="#LinkProperty">LinkProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  link = db.LinkProperty()

m = MyModel()
m.link = db.Link("http://www.google.com/")
</pre>
    <p>In XML, this is an Atom <code>link</code> element.  See <a href="http://www.atomenabled.org/developers/syndication/#link">the Atom specification</a>.</p>
  </dd>

  <dt id="PhoneNumber"><span class="type">class</span>&nbsp;<span class="itemname">PhoneNumber</span>(<span class="argname">phone</span>)</dt>
  <dd>
    <p>A human-readable telephone number.  This is a subclass of the built-in <code>unicode</code> type.</p>
    <p><i>Model property:</i> <a href="#PhoneNumberProperty">PhoneNumberProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  phone = db.PhoneNumberProperty()

m = MyModel()
m.phone = db.PhoneNumber("1 (206) 555-1212")
</pre>
    <p>In XML, this is a <code>gd.phoneNumber</code> element.  See <a href="http://code.google.com/apis/gdata/common-elements.html#gdPhoneNumber">the GData API reference</a>.</p>
  </dd>

  <dt id="PostalAddress"><span class="type">class</span>&nbsp;<span class="itemname">PostalAddress</span>(<span class="argname">address</span>)</dt>
  <dd>
    <p>A postal address.  This is a subclass of the built-in <code>unicode</code> type.</p>
    <p><i>Model property:</i> <a href="#PostalAddressProperty">PostalAddressProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  address = db.PostalAddressProperty()

m = MyModel()
m.address = db.PostalAddress("1600 Ampitheater Pkwy., Mountain View, CA")
</pre>
    <p>In XML, this is a <code>gd:postalAddress</code> element.  See <a href="http://code.google.com/apis/gdata/common-elements.html#gdPostalAddress">the GData API reference</a>.</p>
  </dd>

  <dt id="Rating"><span class="type">class</span>&nbsp;<span class="itemname">Rating</span>(<span class="argname">rating</span>)</dt>
  <dd>
    <p>A user-provided rating for a piece of content, as an integer between 0 and 100.  This is a subclass of the built-in <code>long</code> type.  The class validates that the value is an integer between 0 and 100, and raises a <a href="exceptions.html#BadValueError">BadValueError</a> if the value is invalid.</p>
    <p><i>Model property:</i> <a href="#RatingProperty">RatingProperty</a></p>
    <pre class="prettyprint">
class MyModel(db.Model):
  rating = db.RatingProperty()

m = MyModel()
m.rating = db.Rating(97)
</pre>
    <p>In XML, this is a <code>gd:rating</code> element.  See <a href="http://code.google.com/apis/gdata/common-elements.html#gdRating">the GData API reference</a>.</p>
  </dd>

</dl>


<h2 id="Property_Classes">Property Classes</h2>

<p>All model property classes provided by <code>google.appengine.ext.db</code> are subclasses of the <a href="propertyclass.html">Property</a> base class, and support all of the base constructor's arguments.  See the base class documentation for information about those arguments.</p>

<p>The <code>google.appengine.ext.db</code> package provides the following model property classes:</p>

<dl class="apireference">

  <dt id="BlobProperty"><span class="type">class</span>&nbsp;<span class="itemname">BlobProperty</span>(...)</dt>
  <dd>
    <p>A binary data property.</p>
    <p>Blob data is a byte string.  For text data, which may involve encoding, use <a href="#TextProperty">TextProperty</a>.</p>
    <p><i>Value type:</i> <a href="#Blob">Blob</a></p>
  </dd>

  <dt id="BooleanProperty"><span class="type">class</span>&nbsp;<span class="itemname">BooleanProperty</span>(...)</dt>
  <dd>
    <p>A Boolean property.</p>
    <p><i>Value type:</i> <a href="#bool">bool</a></p>
  </dd>

  <dt id="ByteStringProperty"><span class="type">class</span>&nbsp;<span class="itemname">ByteStringProperty</span>(<span class="argname">verbose_name</code>=<span class="argdefault">None</span>, ...)</dt>
  <dd>
    <p>A short blob property (a "byte string").  Takes a <a href="#ByteString">ByteString</a> value of 500 bytes or less.</p>
    <p>ByteStringProperty property values are indexed, and can be used in filters and sort orders.</p>
    <p>Like <a href="#StringProperty">StringProperty</a>, except the value is not encoded in any way.  The bytes are stored literally.</p>
    <p><i>Value type:</i> <a href="#ByteString">ByteString</a></p>
  </dd>

  <dt id="CategoryProperty"><span class="type">class</span>&nbsp;<span class="itemname">CategoryProperty</span>(...)</dt>
  <dd>
    <p>A category or "tag," a descriptive word or phrase.</p>
    <p><i>Value type:</i> <a href="#Category">Category</a></p>
  </dd>

  <dt id="DateProperty"><span class="type">class</span>&nbsp;<span class="itemname">DateProperty</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">auto_now</span>=<span class="argdefault">False</span>, <span class="argname">auto_now_add</span>=<span class="argdefault">False</span>, ...)</dt>
  <dd>
    <p>A date property, without a time of day.  See <a href="#DateTimeProperty">DateTimeProperty</a> for more information.</p>
    <p><i>Value type:</i> <code>datetime.date</code>.  This is converted to a <a href="#datetime">datetime.datetime</a> internally.</p>
  </dd>

  <dt id="DateTimeProperty"><span class="type">class</span>&nbsp;<span class="itemname">DateTimeProperty</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">auto_now</span>=<span class="argdefault">False</span>, <span class="argname">auto_now_add</span>=<span class="argdefault">False</span>, ...)</dt>
  <dd>
    <p>A date and time property.</p>
    <p>If <span class="argname">auto_now</span> is <code>True</code>, the property value is set to the current time whenever the model instance is stored in the datastore, overwriting the property's previous value.  This is useful for tracking a "last modified" date and time for a model instance.</p>
    <p>If <span class="argname">auto_now_add</span> is <code>True</code>, the property value is set to the current time the first time the model instance is stored in the datastore, unless the property has already been assigned a value.  This is useful for storing a "created" date and time for a model instance.</p>
    <p>Date-time values are stored as and returned using the UTC time zone.  See <a href="#datetime">datetime.datetime</a> for a discussion of how to manage time zones.</p>
    <p><i>Value type:</i> <a href="#datetime">datetime.datetime</a></p>
  </dd>

  <dt id="EmailProperty"><span class="type">class</span>&nbsp;<span class="itemname">EmailProperty</span>(...)</dt>
  <dd>
    <p>An email address.</p>
    <p>Neither the property class nor the value class perform validation of email addresses, they just store the value.</p>
    <p><i>Value type:</i> <a href="#Email">Email</a></p>
  </dd>

  <dt id="FloatProperty"><span class="type">class</span>&nbsp;<span class="itemname">FloatProperty</span>(...)</dt>
  <dd>
    <p>A floating point number property.</p>
    <p><i>Value type:</i> <a href="#float">float</a></p>
  </dd>

  <dt id="GeoPtProperty"><span class="type">class</span>&nbsp;<span class="itemname">GeoPtProperty</span>(...)</dt>
  <dd>
    <p>A geographical point represented by floating-point latitude and longitude coordinates.</p>
    <p><i>Value type:</i> <a href="#GeoPt">GeoPt</a></p>
  </dd>

  <dt id="IMProperty"><span class="type">class</span>&nbsp;<span class="itemname">IMProperty</span>(...)</dt>
  <dd>
    <p>An instant messaging handle.</p>
    <p><i>Value type:</i> <a href="#IM">IM</a></p>
  </dd>

  <dt id="IntegerProperty"><span class="type">class</span>&nbsp;<span class="itemname">IntegerProperty</span>(...)</dt>
  <dd>
    <p>An integer property.</p>
    <p>Python <code>int</code> values are converted to Python <code>long</code> values prior to storage.  A value stored as an <code>int</code> will be returned as a <code>long</code>.</p>
    <p><i>Value type:</i> <a href="#int">int or long</a></p>
  </dd>

  <dt id="LinkProperty"><span class="type">class</span>&nbsp;<span class="itemname">LinkProperty</span>(...)</dt>
  <dd>
    <p>A fully qualified URL.</p>
    <p><i>Value type:</i> <a href="#Link">Link</a></p>
  </dd>

  <dt id="ListProperty"><span class="type">class</span>&nbsp;<span class="itemname">ListProperty</span>(<span class="argname">item_type</span>, <span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">default</span>=<span class="argdefault">None</a>, ...)</dt>
  <dd>
    <p>A list of values of the type given as <span class="argname">item_type</span>.</p>
    <p>In a query, comparing a list property to a value performs the test against the list members: <code>list_property = value</code> tests if the value appears anywhere in the list, <code>list_property &lt; value</code> tests if any of the members of the list are less than the given value, and so forth.</p>
    <p>A query cannot compare two list values.  There is no way to test two lists for equality without testing each element for membership separately.</p>
    <p><span class="argname">item_type</span> is the type of the items in the list, as a Python type or class.  All items in the list value must be of the given type.  <span class="argname">item_type</span> must be one of the datastore value types, and cannot be <code>list</code>.  See <a href="#Datastore_Value_Types">Datastore Value Types</a>, above.</p>
    <p>The value of a ListProperty static property cannot be <code>None</code>.  It can, however, be an empty list.</p>
    <p class="note"><b>Tip:</b> Because ListProperty aggregate types do not use the Property classes, Property class features such as automatic values and validation are not applied automatically to members of the list value.  If you want to validate a member value using a Property class, you can instantiate the class and call its <a href="propertyclass.html#Property_validate">validate()</a> method on the value.</p>
    <p><span class="argname">default</span> is the default value for the list property.  If <code>None</code>, the default is an empty list.  A list property can define a custom <span class="argname">validator</span> to disallow the empty list.</p>
    <p>See <a href="entitiesandmodels.html#Lists">Entities and Models</a> for more information on ListProperty and list values.</p>
    <p><i>Value type:</i> a Python <a href="#list">list</a> of zero or more values, where each value is of the configured type</p>
  </dd>

  <dt id="PhoneNumberProperty"><span class="type">class</span>&nbsp;<span class="itemname">PhoneNumberProperty</span>(...)</dt>
  <dd>
    <p>A human-readable telephone number.</p>
    <p><i>Value type:</i> <a href="#PhoneNumber">PhoneNumber</a></p>
  </dd>

  <dt id="PostalAddressProperty"><span class="type">class</span>&nbsp;<span class="itemname">PostalAddressProperty</span>(...)</dt>
  <dd>
    <p>A postal address.</p> 
    <p><i>Value type:</i> <a href="#PostalAddress">PostalAddress</a></p>
  </dd>

  <dt id="RatingProperty"><span class="type">class</span>&nbsp;<span class="itemname">RatingProperty</span>()</dt>
  <dd>
    <p>A user-provided rating for a piece of content, as an integer between 0 and 100.</p> 
    <p><i>Value type:</i> <a href="#Rating">Rating</a></p>
  </dd>

  <dt id="ReferenceProperty"><span class="type">class</span>&nbsp;<span class="itemname">ReferenceProperty</span>(<span class="argname">reference_class</span>=<span class="argdefault">None</span>, <span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">collection_name</span>=<span class="argdefault">None</code>, ...)</dt>
  <dd>
    <p>A reference to another model instance.  For example, a reference may indicate a many-to-one relationship between the model with the property and the model referenced by the property.</p>
    <p><span class="argname">reference_class</span> is the model class of the model instance being referenced.  If specified, only model instances of the class can be assigned to this property.  If <code>None</code>, any model instance can be the value of this property.</p>
    <p><span class="argname">collection_name</span> is the name of the property to give to the referenced model class whose value is a <a href="queryclass.html">Query</a> for all entities that reference the entity.  If no <span class="argname">collection_name</span> is set, then <code><i>modelname</i>_set</code> (with the name of the model in lowercase letters and "_set" added) is used.</p>
    <p class="note"><b>Note:</b> <span class="argname">collection_name</span> must be set if there are multiple properties within the same model referencing the same model class.  Otherwise, a <code>DuplicatePropertyError</code> will be raised when the default names are generated.</p>
    <p>ReferenceProperty automatically references and dereferences model instances as property values: A model instance can be assigned to a ReferenceProperty directly, and its key will be used.  The ReferenceProperty value can be used as if it were a model instance, and the datastore entity will be fetched and the model instance created when it is first used in this way.  Untouched reference properties do not query for unneeded data.</p>
    <pre class="prettyprint">
class Author(db.Model):
  name = db.StringProperty()

class Story(db.Model):
  author = db.ReferenceProperty(Author)

story = db.get(story_key)
author_name = story.author.name
</pre>
    <p>As with a <a href="keyclass.html">Key</a> value, it is possible for a reference property value to refer to a data entity that does not exist.  If a referenced entity is deleted from the datastore, references to the entity are not updated.  An application can explicitly <a href="functions.html#get">db.get()</a> the value of a ReferenceProperty (which is a <a href="keyclass.html">Key</a>) to test whether the referenced entity exists.</p>
    <p>Deleting an entity does not delete entities referred to by a ReferenceProperty.</p>
    <p>See also <a href="entitiesandmodels.html#References">this introduction to reference properties</a>.</p>
    <p><i>Value type:</i> <a href="keyclass.html">db.Key</a> (<a href="#db_Key">see above</a>)</p>
  </dd>

  <dt id="SelfReferenceProperty"><span class="type">class</span>&nbsp;<span class="itemname">SelfReferenceProperty</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">collection_name</span>=<span class="argdefault">None</span>, ...)</dt>
  <dd>
    <p>A reference to another model instance of the same class.  See <a href="#ReferenceProperty">ReferenceProperty</a>.</p>
    <p><i>Value type:</i> <a href="keyclass.html">db.Key</a> (<a href="#db_Key">see above</a>)</p>
  </dd>

  <dt id="StringListProperty"><span class="type">class</span>&nbsp;<span class="itemname">StringListProperty</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">default</span>=<span class="argdefault">None</span>, ...)</dt>
  <dd>
    <p>Similar to a <a href="#ListProperty">ListProperty</a> of Python <code>str</code> or <code>unicode</code> (<code>basestring</code>) values.  See <a href="#ListProperty">ListProperty</a>.</p>
    <p><i>Value type:</i> a Python <code>list</code> of <a href="#str">str or unicode</a> values</p>
  </dd>

  <dt id="StringProperty"><span class="type">class</span>&nbsp;<span class="itemname">StringProperty</span>(<span class="argname">verbose_name</code>=<span class="argdefault">None</span>, <span class="argname">multiline</code>=<span class="argdefault">False</span>, ...)</dt>
  <dd>
    <p>A short string property.  Takes a Python <code>str</code> or <code>unicode</code> (<code>basestring</code>) value of 500 bytes or less.</p>
    <p>StringProperty property values are indexed, and can be used in filters and sort orders.</p>
    <p>If <span class="argname">multiline</span> is <code>False</code>, then the value cannot include linefeed characters.  The <code>djangoforms</code> library uses this to enforce a difference between text fields and textarea fields in the data model, and others can use it for a similar purpose.</p>
    <p><i>Value type:</i> <a href="#str">str or unicode</a></p>
  </dd>

  <dt id="TextProperty"><span class="type">class</span>&nbsp;<span class="itemname">TextProperty</span>()</dt>
  <dd>
    <p>A long string.</p>
    <p>Unlike <a href="#StringProperty">StringProperty</a>, a TextProperty value can be more than 500 bytes long.  However, TextProperty values are not indexed, and cannot be used in filters or sort orders.</p>
    <p>TextProperty values store text with a text encoding.  For binary data, use <a href="#BlobProperty">BlobProperty</a>.</p>
    <p><i>Value type:</i> <a href="#Text">Text</a></p>
  </dd>

  <dt id="TimeProperty"><span class="type">class</span>&nbsp;<span class="itemname">TimeProperty</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">auto_now</span>=<span class="argdefault">False</span>, <span class="argname">auto_now_add</span>=<span class="argdefault">False</span>, ...)</dt>
  <dd>
    <p>A time property, without a date.  Takes a Python standard library <span class="itemname">datetime.time</span> value.  See <a href="#DateTimeProperty">DateTimeProperty</a> for more information.</p>
    <p><i>Value type:</i> <code>datetime.time</code>.  This is converted to a <a href="#datetime">datetime.datetime</a> internally.</p>
  </dd>

  <dt id="UserProperty"><span class="type">class</span>&nbsp;<span class="itemname">UserProperty</span>(<span class="argname">verbose_name</span>=<span class="argdefault">None</span>, <span class="argname">auto_current_user</span>=<span class="argdefault">False</span>, <span class="argname">auto_current_user_add</span>=<span class="argdefault">False</span>, ...)</dt>
  <dd>
    <p>A user with a Google account.</p>
    <p>If <span class="argname">auto_current_user</span> is <code>True</code>, the property value is set to the currently signed-in user whenever the model instance is stored in the datastore, overwriting the property's previous value.  This is useful for tracking which user modifies a model instance.</p>
    <p>If <span class="argname">auto_current_user_add</span> is <code>True</code>, the property value is set to the currently signed-in user the first time the model instance is stored in the datastore, unless the property has already been assigned a value.  This is useful for tracking which user creates a model instance, which may not be the same user that modifies it later.</p>
    <p>UserProperty does not accept a default value.  Default values are set when the model class is first imported, and with import caching may not be the currently signed-in user.</p>
    <p><i>Value type:</i> <a href="../users/userclass.html">users.User</a>  (<a href="#users_User">see above</a>)</p>
  </dd>

</dl>



      </div><!-- end gc-pagecontent -->
   </div><!-- end gooey wrapper -->

    </div> <!-- end codesite content -->

<div id="gc-footer" dir="ltr">
  <div class="text">
    
      <div class="notice"><div id="notice" style="text-align: center; border: 1em 0em 1em 0em">
  Except as otherwise <a
  href="http://code.google.com/policies.html#restrictions">noted</a>,
  the content of this page is licensed under the <a rel="license"
  href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
  Attribution 2.5 License</a>, and code samples are licensed under the
  <a rel="license" href="http://www.apache.org/licenses/LICENSE-2.0">Apache
  2.0 License</a>.
<!-- <rdf:RDF xmlns="http://web.resource.org/cc/" 
              xmlns:dc="http://purl.org/dc/elements/1.1/"
              xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <Work rdf:about="">
    <license rdf:resource="http://creativecommons.org/licenses/by/2.5/" />
  </Work>
  <License rdf:about="http://creativecommons.org/licenses/by/2.5/">
    <permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
    <permits rdf:resource="http://web.resource.org/cc/Distribution"/>
    <requires rdf:resource="http://web.resource.org/cc/Notice"/>
    <requires rdf:resource="http://web.resource.org/cc/Attribution"/>
    <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
  </License>
</rdf:RDF> -->
</div>
Java is a registered trademark of Sun Microsystems, Inc.</div>
    
    &copy;2009 Google -
    <a href="http://code.google.com">Code Home</a> -
    <a href="http://www.google.com/accounts/TOS">Terms of Service</a> -
    <a href="http://www.google.com/privacy.html">Privacy Policy</a> -
    <a href="http://code.google.com/more">Site Directory</a>
    <br /> <br />
    Google Code offered in:
    <a href="http://code.google.com/intl/en">English</a> -
    <a href="http://code.google.com/intl/es">Español</a> -
    <a href="http://code.google.com/intl/ja">日本語</a> -
    <a href="http://code.google.com/intl/ko">한국어</a> -
    <a href="http://code.google.com/intl/pt-BR">Português</a> -
    <a href="http://code.google.com/intl/ru">Pусский</a> -
    <a href="http://code.google.com/intl/zh-CN">中文(简体)</a> -
    <a href="http://code.google.com/intl/zh-TW">中文(繁體)</a>
  </div>
</div><!-- end gc-footer -->

</div><!-- end gc-containter -->

<script type="text/javascript">CODESITE_CSITimer['load'].tick('ats');</script>
<script src="../../../../js/codesite_tail.pack.04102009.js" type="text/javascript"></script>






  </body>
</html>


